#!/bin/bash
# Lists the files that are in only one of the two directories

diffResultFile=DirDiff.txt
#diff -q -r CodePatterns CodePatternsTest/codepattern 
# Ignore fi
#-B  --ignore-blank-lines       Ignore changes whose lines are all blank.
#-q  --brief       Output only whether files differ.
#-e  --ed       Output an ed script.
#-r  --recursive        Recursively compare any subdirectories found.
#-x PAT  --exclude=PAT        Exclude files that match PAT.
# -N  --new-file       Treat absent files as empty.
diff -B -q -r -x ".svn" $1 $2 > $diffResultFile

firstDirName=`basename $1`
secondDirName=`basename $2`

echo $secondDirName $firstDirName
echo "replace ": " with /  and Only in with %OPER_CMD%"
echo "SET OPER_CMD=rm -f" > OnlyIn${firstDirName}.bat
grep -E "$Only in $1" $diffResultFile | sed -e "s/: /\//g" -e "s/Only in/%OPER_CMD%/g" >> OnlyIn${firstDirName}.bat

echo "SET OPER_CMD=rm -f" > OnlyIn${secondDirName}.bat
grep -E "$Only in $2" $diffResultFile | sed -e "s/: /\//g" -e "s/Only in/%OPER_CMD%/g" >> OnlyIn${secondDirName}.bat
#grep -E "$Only in $2" $diffResultFile > OnlyIn${secondDirName}.txt

# list of files in svn repository
#svn st -V > SVNRepoFileList.txt
#awk '{ if($1 != "?") print $NF ; }' SVNRepoFileList.txt